package com.naiterui.ehp.bs.wechat.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.naiterui.ehp.bp.support.exception.BaseExceptionCodes;
import com.naiterui.ehp.bp.support.exception.PublicService;
import com.naiterui.ehp.bp.support.exception.ResponseVO;
import com.naiterui.ehp.bs.wechat.config.WeChatConfig;
import com.naiterui.ehp.bs.wechat.properties.WeChatProperties;
import com.naiterui.ehp.bs.wechat.utils.WeChatApiUtil;

/**
 * @author zhoupeipei
 * @date 2019-06-14 15:10
 * @since 1.0.0
 */
@RequestMapping("ap/inner/access")
@RestController
public class InnerAccessTokenController {
    private static final Logger LOGGER = LoggerFactory.getLogger(InnerAccessTokenController.class);
    @Autowired
    WeChatConfig weChatConfig;

    @RequestMapping("refresh")
    public ResponseVO<Void> refreshAccessToken() throws Exception {
        WeChatProperties configProperties = weChatConfig.paProperties();
        WeChatApiUtil.refreshAccessToken(configProperties.getAppId(), configProperties.getAppSecret());
        return PublicService.returnResponseVO(BaseExceptionCodes.SUCCESS);
    }
}
